package com.briup.app06.web.controller;
import com.briup.app06.bean.UserInfo;
import com.briup.app06.service.IUserInfoService;
import com.briup.app06.utils.Message;
import com.briup.app06.utils.MessageUtil;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotNull;
import java.util.List;

@RestController

@Validated

@RequestMapping("/userInfo")

public class UserInfoController {

    @Autowired
    private IUserInfoService userInfoService;

    @GetMapping("query")
    public Message query(String realname,String gender){
        List<UserInfo> list =  userInfoService.query(realname,gender);
        return MessageUtil.success(list);
    }



    @PostMapping("saveOrUpdate")
    public Message saveOrUpdate(UserInfo info){
        userInfoService.saveOrUpdate(info);
        return MessageUtil.success("操作成功");
    }



    @DeleteMapping("deleteById")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "用户编号", required = true, paramType = "query"),

    })

    public Message deleteById( @NotNull Long id){
        userInfoService.deleteById(id);
        return MessageUtil.success("操作成功");
    }

}


